home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / BBS / MUBBS / MUBBS etc.cpt / Module Source / E-mail / CheckForEmail.c < prev    next >
Text File  |  1991-11-21  |  8KB  |  269 lines

  1. /* *********************************************************************************
  2.      
  3.       MODULE:        CheckForEmail Module
  4.       
  5.      DESCRIPTION:    This CheckForEmail Module is a simple module for MUBBS, the
  6.                      Multi-User Bulliten Board System Software.
  7.                      
  8.      AUTHOR:        Noam Freedman
  9.      
  10.      Copyright © 1990 by Noam Freedman. Portions are also Copyright Symantec Corp.
  11.  
  12.      This program source code and it's compiled version IS NOT IN THE
  13.      PUBLIC DOMAIN ! Please read the "COPYRIGHT NOTICE / NMF" file for details
  14.      regarding use of this program source code and it's compiled version.
  15.      
  16.      Revision History:
  17.      ============================================================
  18.      10/20/91 - Started programming
  19.      11/ 4/91 - Edited for release
  20.      ============================================================
  21.      
  22.  
  23.     ******************************************************************************** */
  24.  
  25.  
  26. #define        INMAIN
  27.  
  28.  
  29. #include    "MUBBS Module.h"
  30. #include    "Email.h"
  31. #include    <SetUpA4.h>
  32.  
  33. /* my globals for this module */
  34.  
  35.  
  36.  
  37. pascal void main (mode1,G1,P1) /* called from the main routines, and what mode to be in */
  38. int mode1;
  39. struct GS *G1; /* we point to the "global" struct in the Main Module here */
  40. Ptr P1; /* we ignore this pointer, we do not use it at all */
  41. {
  42. Handle temph;
  43. float version = 0.5; /* what version of MUBBS you are compatable with IE: .5 and above */
  44. RememberA0(); SetUpA4(); /* This sets up the A4 register to access our globals */
  45. asm { _RecoverHandle }; asm {move.l a0,temph}; HLock(temph); /* locks our module, do this ! */
  46.  
  47. G=G1; /* This MUST be the first thing you do in main only, it sets up the struct globals */
  48. mode[u]=mode1; /* set up our mode so that you can read it anywhere */
  49.  
  50. switch (mode[u]) { /* any un-handled modes return error from this module */
  51.     case 2:
  52.         dostuff();
  53.         G->moduleresult=0;
  54.         break;
  55.     case 98:
  56.         versionck(version); /* just return after this call, don't modify anything */
  57.         break;        
  58.     case 0:
  59.         strcpy (G->programmer,"Noam Freedman"); /* show the programmer's name up to 20 chars*/
  60.         G->moduleresult=0; /* this was also a init call if we need close call put 99 here */
  61.         break;
  62.     default:
  63.         G->moduleresult=1; /* return bad code */
  64.     };
  65.  
  66. HUnlock(temph); /* unlocks this module, do this ! */
  67. RestoreA4(); /* call this when you are all done */
  68. }
  69.  
  70.  
  71.  
  72. dostuff()
  73. {
  74. char pad[100]; /* this is a fix for a problem */
  75. FILE *fp_headers;
  76. int choice, i, num, r, deleteflag;
  77. char tempstring[10], ch;
  78. char pad2[100]; /* this is a fix for a problem */
  79. struct LoadStruct S;
  80. struct MsgStruct MsgInfo;
  81. struct EnterStruct E;
  82.  
  83. if (!G->online[u]) { num = 2;goto byebye; } /* do this check so we can log out if hang up */
  84.  
  85. loguser("In E-Mail Module"); /* this tells where you are for remote sysop, or writes to log file */
  86.  
  87. /* you print the following so that the sysop can monitor use on the mac screen */
  88.  
  89. print("C> Line %d %s, at: E-Mail\n",(u+1),G->username[u]);
  90.  
  91. while (TRUE)
  92.     {
  93.     if(!cmd1("]]   *** E-Mail Menu ***]]>> Read, Send, Help, Quit : ")) goto byebye;
  94.     send(G->CR[u]);
  95.     ch = G->input[u];
  96.     switch(ch)
  97.         {
  98.         case 'H':
  99.                 send("]E-Mail Menu:");
  100.                 send("]");
  101.                 send("]     This the main E-Mail menu, you select if you want to read");
  102.                 send("]or send some mail to another person. To delete a message, read it first:");
  103.                 send("]");
  104.                 send("]R)ead     - Checks for any existing mail and allows you to read it.");
  105.                 send("]");
  106.                 send("]S)end     - Allows you to send mail to another user.");
  107.                 send("]");
  108.                 send("]H)elp     - Displays this file.");
  109.                 send("]");
  110.                 send("]Q)uit     - Leaves E-Mail.");
  111.                 send("]");
  112.                 break;                            
  113.         case 'R':
  114.                 goto CheckEmail;
  115.                 break;                    
  116.         case 'S':
  117.                 goto SendEmail;
  118.                 break;
  119.         case 'Q':
  120.                 goto byebye;
  121.                 break;
  122.                             
  123.  
  124.         }
  125.  
  126. continue; /* back to start of while */
  127.  
  128. CheckEmail:
  129.  
  130. module (3,"check_email",&S);
  131.  
  132. if (S.result == 20)
  133.     {
  134.     send("]You have %i or more pieces of mail.  To view MORE you must delete some.]",MAXEMAIL);
  135.     }
  136. if (S.result == 21)
  137.     {
  138.     send("]You have no mail at this time.]");
  139.     continue;
  140.     }
  141.  
  142. if (S.result != 0) continue;
  143.  
  144. AskQuestion: /* this is default (S.result = 0) */
  145.  
  146. r = 0;
  147.  
  148. send("]You have mail from:]]");                
  149.  
  150. for ( i=1 ; i<=S.numemail ; i++)
  151.     {
  152.     send("%i)  %s   %s]",i,S.FromUser[i],S.title[i]);
  153.     }
  154. send("]>> # to read, (return=first), Quit : ");
  155. portsin(tempstring, 2);
  156. send(G->CR[u]);
  157. if (! G->online[u]) goto byebye;
  158. if (tempstring[0] == 'Q') continue; /* go back to main menu */
  159. if (tempstring[0] == 'q') continue;
  160. S.choice=strtoint(tempstring,"%i",&S.choice);
  161. if ( S.choice == 0) S.choice=1;
  162. if ( S.choice > S.numemail ) {
  163.     send("]Invalid choice, please try again.]]");
  164.     goto AskQuestion;
  165.     }
  166.     
  167. send(G->CR[u]);
  168.  
  169. DisplayMessage:
  170. module(3,"display_email",&S);
  171.  
  172. send ("]-END-");
  173. if (S.choice == 1) send ("   (Please delete your mail when you are done with it)]");
  174. else send(G->CR[u]);
  175. back:
  176.     if(!cmd1("]>> Email sender, Delete, Re-read, + (return), -, Help, Quit : ")) goto byebye;
  177.     send(G->CR[u]);
  178.     ch = G->input[u];
  179.     switch(ch)
  180.         {
  181.         case 'H':
  182.                 send("]E-Mail Prompt:");
  183.                 send("]");
  184.                 send("]     The E-mail prompt is shown after a e-mail message has been");
  185.                 send("]shown. There are 8 option to choose from:");
  186.                 send("]");
  187.                 send("]E)mail sender  - Begins an e-mail message addressed to the");
  188.                 send("]                 person who sent you the last message you read.");
  189.                 send("]");
  190.                 send("]D)elete        - Deletes the current e-mail message.");
  191.                 send("]");
  192.                 send("]R)e-read       - Displays the last e-mail message again.");
  193.                 send("]");
  194.                 send("]+              - Advances to the next e-mail message (or hit RETURN).");
  195.                 send("]");
  196.                 send("]-              - Retreats to the previous e-mail message.");
  197.                 send("]");
  198.                 send("]H)elp          - Displays this file.");
  199.                 send("]");
  200.                 send("]Q)uit          - Returns to E-Mail Main Menu.");
  201.                 send("]");
  202.                 break;                            
  203.         case 'R':
  204.                 goto DisplayMessage;
  205.                 break;
  206.                             
  207.         case 'E':
  208.                 if (!cmd1("]Delete this message first (Y/N) (return=YES) ? ") )  return;
  209.                 send(G->CR[u]);
  210.                 deleteflag=FALSE;
  211.                 if (G->input[u] != 'N')
  212.                     {
  213.                     module(3,"delete_email",&S); /* delete it */
  214.                     deleteflag=TRUE;
  215.                     }
  216.                 strcpy(E.ToUser,S.FromUser[S.choice]); /* set this to the sender's name */
  217.                 module(3,"enter_email",&E); /* call the enter module */
  218.                 if (E.result ==10) module(3,"save_email",&E); /* call the save module */
  219.                 if (deleteflag) {
  220.                     module (3,"check_email",&S); /* do the check again */
  221.                     if (S.result == 21) continue; /* no more mail */
  222.                     if (S.result != 0) continue; /* or fall through to + */
  223.                     }
  224.                 goto fall;
  225.                 break;
  226.         case 'Q':
  227.                 continue;                            
  228.                             
  229.         case '-':
  230.                 if (S.choice <= 1)
  231.                     S.choice = S.numemail;
  232.                 else
  233.                     S.choice = S.choice - 1;
  234.                 goto DisplayMessage;
  235.                 break;
  236.  
  237.         case 'D':
  238.                 module(3,"delete_email",&S); /* delete it */
  239.                 module (3,"check_email",&S); /* do the check again */
  240.  
  241.                 if (S.result == 21) continue; /* no more mail */
  242.                 if (S.result != 0) continue; /* or fall through to + */
  243.         case '+':
  244.         case '\r':
  245.         
  246.         fall:
  247.                 if (S.choice >= S.numemail)
  248.                     S.choice = 1;
  249.                 else
  250.                     S.choice = S.choice + 1;
  251.                 goto DisplayMessage;
  252.                 break;
  253.         }
  254. goto back;
  255.  
  256.     
  257. SendEmail:
  258.  
  259. strcpy(E.ToUser,""); /* set this to blank so it asks for a user's name */
  260. module(3,"enter_email",&E); /* call the enter module */
  261. if (E.result == 10) module(3,"save_email",&E); /* call the save module */
  262.  
  263.  
  264. } /* closes "main menu" while loop */
  265.  
  266. byebye:
  267. return;
  268. }
  269.